package cn.iocoder.yudao.module.design.dal.mysql.probleminnerrel;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.design.controller.admin.probleminnerrel.vo.ProblemInnerRelExportReqVO;
import cn.iocoder.yudao.module.design.controller.admin.probleminnerrel.vo.ProblemInnerRelPageReqVO;
import cn.iocoder.yudao.module.design.dal.dataobject.probleminnerrel.ProblemInnerRelDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 问题间关联 Mapper
 *
 * @author czw
 */
@Mapper
public interface ProblemInnerRelMapper extends BaseMapperX<ProblemInnerRelDO> {

    default PageResult<ProblemInnerRelDO> selectPage(ProblemInnerRelPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProblemInnerRelDO>()
                .eqIfPresent(ProblemInnerRelDO::getHouseId, reqVO.getHouseId())
                .eqIfPresent(ProblemInnerRelDO::getFlowId, reqVO.getFlowId())
                .eqIfPresent(ProblemInnerRelDO::getNodeId, reqVO.getNodeId())
                .eqIfPresent(ProblemInnerRelDO::getProblemId, reqVO.getProblemId())
                .eqIfPresent(ProblemInnerRelDO::getRelProblemId, reqVO.getRelProblemId())
                .betweenIfPresent(ProblemInnerRelDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ProblemInnerRelDO::getDependType, reqVO.getDependType())
                .orderByDesc(ProblemInnerRelDO::getId));
    }

    default List<ProblemInnerRelDO> selectList(ProblemInnerRelExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ProblemInnerRelDO>()
                .eqIfPresent(ProblemInnerRelDO::getHouseId, reqVO.getHouseId())
                .eqIfPresent(ProblemInnerRelDO::getFlowId, reqVO.getFlowId())
                .eqIfPresent(ProblemInnerRelDO::getNodeId, reqVO.getNodeId())
                .eqIfPresent(ProblemInnerRelDO::getProblemId, reqVO.getProblemId())
                .eqIfPresent(ProblemInnerRelDO::getRelProblemId, reqVO.getRelProblemId())
                .betweenIfPresent(ProblemInnerRelDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ProblemInnerRelDO::getDependType, reqVO.getDependType())
                .orderByDesc(ProblemInnerRelDO::getId));
    }

}
